package com.woniu.humanresource.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;


import java.util.Date;

@Component //注入到IOC容器
@Slf4j //日志
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    //插入的填充
    public void insertFill(MetaObject metaObject) {
        log.info("开始插入填充....");
        this.setFieldValByName("gmtCreate",new Date(),metaObject);
        this.setFieldValByName("gmtModified",new Date(),metaObject);
    }
    @Override
    //更新的填充
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("gmtModified",new Date(),metaObject);
    }
}
